<?php

namespace app\dao\office;

use app\dao\BaseDao;
use app\model\office\OfficeMajor;

class OfficeMajorDao extends BaseDao
{

    public function index(array $where)
    {
        return $this->getModel()->where('website_id', $where['website_id'])->paginate($where['pageSize']);
    }

    public function create(array $where)
    {
        return $this->getModel()->create($where);
    }

    public function updateDao(array $where)
    {
        return $this->getModel()->update($where);
    }

    public function deleteDao(array $where)
    {
        return $this->getModel()-> whereIn('id',$where['id']) -> update(['delete_time' => date('Y-m-d H:i:s', time())]);

    }

    public function searchDao(array $where)
    {
        return $this->getModel()->withSearch(['title', 'level', 'major_code'],
            ['title' => $where['title'], 'level' => $where['level'], 'major_code' => $where['major_code']]
        )->where('website_id', $where['website_id'])->paginate($where['pageSize']);
    }

    protected function setModel(): string
    {
        return OfficeMajor::class;
    }
}